package kr.hkit.androidcomplete01.ch06;

import kr.hkit.androidcomplete01.R;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Ch06Main extends ListActivity {
	
	private String[] subList; 
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		subList = getResources().getStringArray(R.array.ch06_list);
		
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(
				this, android.R.layout.simple_list_item_1, subList);
		setListAdapter(adapter);
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		
		Intent intent = null;
		
		switch(position) {
			case 0:
				intent = new Intent(this, CellsizeEx.class);
				break;
			case 1:
				intent = new Intent(this, CellPositionEx.class);
				break;
			case 2:
				intent = new Intent(this, CellspanEx.class);
				break;
			case 3:
				intent = new Intent(this, MultiPageEx.class);
				break;
			case 4:
				intent = new Intent(this, TwoLineInputFormEx.class);
				break;
			case 5 :
				intent = new Intent(this, CodeLayoutEx.class);
				break;
			case 6:
				intent = new Intent(this, CodeLayoutEx2.class);
				break;
			case 7:
				intent = new Intent(this, InflationEx.class);
				break;
			case 8:
				intent = new Intent(this, InflationEx2.class);
				break;
			case 9:
				intent = new Intent(this, InflationEx5.class);
				break;
			case 10:
				intent = new Intent(this, LayoutParameter3Ex.class);
				break;
			case 11:
				intent = new Intent(this, MarginParameter2Ex.class);
				break;
			case 12:
				intent = new Intent(this, SetParameterEx.class);
				break;
			case 13:
				intent = new Intent(this, RelativeParameter.class);
				break;
			default:
				break;
		}
		
		startActivity(intent);
	}
}
